package com.nervenets.web.hibernate.domain.user;

import com.nervenets.web.enumeration.OrderStatus;
import com.nervenets.web.enumeration.OrderType;
import com.nervenets.web.enumeration.PayType;
import com.nervenets.web.hibernate.DomainObject;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Type;

import javax.persistence.Entity;
import javax.persistence.Table;

@Entity
@Table(name = "orders")
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Order extends DomainObject {
    private OrderType orderType;
    private long userId;
    private long unionId;
    private long adminId;
    private long actualPayMoney;
    private OrderStatus status = OrderStatus.init;
    private PayType payType;
    @Type(type = "com.nervenets.web.adapter.jsonType.OrderExtraJson")
    private OrderExtra extra = new OrderExtra();
    private int payTime;//订单支付时间
    private boolean offlinePay = false;

    public Order(OrderType orderType, PayType payType, long userId, long finalMoney, int surplus) {
        this.orderType = orderType;
        this.payType = payType;
        this.userId = userId;
        this.actualPayMoney = finalMoney;
        this.extra.setSurplus(surplus);
    }
}
